{extend name="common/layout" /}
{block name="main"}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{:lang('账单报表')}</legend>
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <input class="layui-input" style="width: 250px;" name="key" id="key" placeholder="{:lang('输入用户名/公司名称/线路名称')}">
        </div>
        <button class="layui-btn" id="search" data-type="reload">{:lang('search')}</button>
        <a class="layui-btn layui-btn-warm" id="downReport" href="{$repotUrl}" target="_blank">{:lang('下载')}</a>
        <div style="clear: both;"></div>
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
{/block}
{block name="footer"}
<script type="text/html" id="title">
    <a href="#" data-href="{:url('view')}?message_id={{d.id}}" class="_title">{{d.title}} 
        {{d.is_red == 0 ? '<span class="layui-badge-dot"></span>' : ''}}
    </a>
</script>
   <script type="text/javascript">
   	layui.use(['table','layer'], function() {
   		 var table = layui.table, $ = layui.jquery, layer = layui.layer;
   		 var tableIn = table.render({
            elem: '#list'
            ,url: '{:url("index")}',
            method:'post',
            page:getPageThume()
            ,cols: [[
                 {field:'id', title: "{:lang('Item')}", width:"8%",sort:true}
                ,{field:'username', title: "{:lang('用户名')}", width:"10%",sort:true}
                ,{field:'company', title: "{:lang('公司名称')}", width:"15%",sort:true}
                ,{field:'name', title: "{:lang('线路名称')}", width:"15%"}
                ,{field:'typelabel', title: "{:lang('网络服务类型')}", width:"13%"}
                ,{field:'area', title: "{:lang('本端接入')}", width:"13%"}
                ,{field:'address', title: "{:lang('本端接入地区')}", width:"13%"}
                ,{field:'rearea', title: "{:lang('对端连接')}", width:"13%"}
                ,{field:'readdress', title: "{:lang('对端连接地区')}", width:"12%"}
                ,{field:'broadband', title: "{:lang('带宽(Mbps)')}", width:"12%",sort:true}
                ,{field:'daylength', title: "{:lang('购买时间(月)')}", width:"12%",sort:true}
            ]]
        });
        //搜索
        $('#search').on('click', function () {
            var key = $('#key').val();
            tableIn.reload({
                where: {key: key},
                done: function(res, curr, count){
                    console.log(res);
                    $("#downReport").attr("href",res.repotUrl);
                }
            });
        });

    })
   </script>
{/block}